<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
    <!ENTITY nbsp "&#xA0;">
    <!ENTITY nl "&#xD;&#xA;">
]>

<!-- stylesheet for mimetype "application/vnd.oasis.opendocument.text" -->

<!-- Version and namespaces -->
<xsl:stylesheet version="1.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
    xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
    xmlns:int="http://opendocumentfellowship.org/internal"
    xmlns:math="http://www.w3.org/1998/Math/MathML"
    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
    xmlns:ooo="http://openoffice.org/2004/office"
    xmlns:oooc="http://openoffice.org/2004/calc"
    xmlns:ooow="http://openoffice.org/2004/writer"
    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
    xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="anim chart config dc dr3d draw fo form int math meta number
        office ooo oooc ooow presentation script smil style svg table text xforms xlink #default">

<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

    <!-- define the mimetype for this document -->
    <xsl:variable name="mimetype">application/vnd.oasis.opendocument.text</xsl:variable>

<!-- STYLES: templates for generating most of the CSS declarations START - = - = - = - = - = - = - = - = - = - = - = -->

<!-- /* templates for creating the header (styles) */ -->

    <xsl:template match="style:default-style">
        <xsl:choose>
            <xsl:when test="@style:family='table'"><xsl:text> table</xsl:text></xsl:when>
            <xsl:when test="@style:family='table-cell'"><xsl:text> td</xsl:text></xsl:when>
            <xsl:when test="@style:family='table-row'"><xsl:text> tr</xsl:text></xsl:when>
            <xsl:when test="@style:family='paragraph'"><xsl:text> div</xsl:text></xsl:when> <!-- using div for p tags -->
            <xsl:when test="@style:family='text'"><xsl:text> span</xsl:text></xsl:when>
            <xsl:otherwise>
                <xsl:text>&nl;.default_</xsl:text>
                <xsl:value-of select="translate(@style:family,'.,;: %()[]/\+','_____________')" />
            </xsl:otherwise>
        </xsl:choose>
        <xsl:text> { </xsl:text>
        <xsl:call-template name="readProperties" />
        <xsl:text>}&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="style:style">
        <xsl:text>&nl;.</xsl:text>
        <xsl:call-template name="classInheritance">
            <xsl:with-param name="styleName"><xsl:value-of select="@style:name" /></xsl:with-param>
            <xsl:with-param name="class">
                <xsl:value-of select="translate(@style:name,'.,;: %()[]/\+','_____________')" />
            </xsl:with-param>
            <xsl:with-param name="separator"><xsl:text>.</xsl:text></xsl:with-param><!-- Combined Class Selector -->
        </xsl:call-template>
        <xsl:text> { </xsl:text>
        <xsl:call-template name="readProperties" />
        <xsl:text>} </xsl:text>
    </xsl:template>

    <xsl:template name="readProperties">
        <xsl:apply-templates select="style:page-layout-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:header-footer-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:text-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:paragraph-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:section-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:ruby-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:list-level-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-column-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-row-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:table-cell-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:graphic-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:drawing-page-properties/@*" mode="styleattr" />
        <xsl:apply-templates select="style:chart-properties/@*" mode="styleattr" />
    </xsl:template>

<!-- FORMATTING PROPERTIES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template
        match="@fo:background-color | @fo:color | @fo:font-family | @svg:font-family | @fo:font-style |
            @fo:font-variant | @fo:font-weight | @fo:letter-spacing | @fo:text-transform | @fo:text-shadow |
            @fo:text-indent | style:ruby-align"
        mode="styleattr">
        <xsl:value-of select="local-name()" /><xsl:text>: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@fo:font-size" mode="styleattr">
        <!-- be careful on sub/super instances, if it exists, its size takes precedence over the normal font-size -->
        <xsl:if test="not(../@style:text-position) and not(contains(../@style:text-position, ' '))">
            <xsl:text>font-size: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="@style:font-name" mode="styleattr">
        <!-- add single quotes if the value is more than one word -->
        <xsl:variable name="thisValue" select="." />
        <xsl:variable name="thisFont">
            <xsl:choose>
                <xsl:when test="contains(., ' ')">
                     <xsl:value-of select='concat("&apos;", ., "&apos;")' />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="." />
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="thisFontFamily" select="$documentContent/office:font-face-decls/style:font-face[@style:name=$thisValue][1]/@svg:font-family" />
        <xsl:variable name="thisFontGeneric" select="$documentContent/office:font-face-decls/style:font-face[@style:name=$thisValue][1]/@style:font-family-generic" />

        <!-- Get the font to be used from the font-family and font-family-generic listed in the font-face-decls -->
        <xsl:text>font-family: </xsl:text>
        <xsl:value-of select="$thisFont" />
        <xsl:if test="(count($thisFontFamily) &gt; 0) and not($thisFont = $thisFontFamily)">
            <xsl:text>, </xsl:text><xsl:value-of select="$thisFontFamily" />
        </xsl:if>
        <xsl:if test="count($thisFontGeneric) &gt; 0">
            <xsl:text>, </xsl:text><xsl:value-of select="$thisFontGeneric" />
        </xsl:if>
        <xsl:text>; </xsl:text>
    </xsl:template>


    <!-- BORDER, MARGINS, PADDING related properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right" mode="styleattr">
        <xsl:variable name="borderType" select="local-name()"/>
        <xsl:choose>
            <xsl:when test=".='none'">
                <xsl:value-of select="$borderType"/>
                <xsl:text>-style: none; </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="borderWidth" select="substring-before(., ' ')"/>
                <xsl:variable name="borderStyle" select="substring-before(substring-after(., ' '), ' ')"/>
                <xsl:variable name="borderColor" select="substring-after(substring-after(., ' '), ' ')"/>

               <!-- More information at template 'round-up-border-width' -->
                <xsl:variable name="borderWidthFixed">
                    <xsl:call-template name="round-up-border-width">
                        <xsl:with-param name="borderWidth" select="$borderWidth"/>
                        <xsl:with-param name="multiplier">
                            <xsl:choose>
                                <xsl:when test="$borderStyle = 'double'">3</xsl:when>
                                <xsl:otherwise>1</xsl:otherwise>
                            </xsl:choose>
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:variable>

                <xsl:value-of select="$borderType"/><xsl:text>-width: </xsl:text>
                <xsl:value-of select="$borderWidthFixed"/><xsl:text>; </xsl:text>
                <xsl:value-of select="$borderType"/><xsl:text>-style: </xsl:text>
                <xsl:value-of select="$borderStyle"/><xsl:text>; </xsl:text>
                <xsl:value-of select="$borderType"/><xsl:text>-color: </xsl:text>
                <xsl:value-of select="$borderColor"/><xsl:text>; </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@style:border-line-width" mode="styleattr">
        <xsl:text>border-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-top" mode="styleattr">
        <xsl:text>border-top-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-bottom" mode="styleattr">
        <xsl:text>border-bottom-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-left" mode="styleattr">
        <xsl:text>border-left-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:border-line-width-right" mode="styleattr">
        <xsl:text>border-right-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@draw:stroke" mode="styleattr">
        <xsl:text>border-style: </xsl:text>
            <xsl:choose>
                <xsl:when test=".='dash'">dashed</xsl:when>
                <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
            </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@svg:stroke-width" mode="styleattr">
        <xsl:text>border-width: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@svg:stroke-color" mode="styleattr">
        <xsl:text>border-color: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <!-- Changing border width measure to cm and enlarging border-width to the Mozilla browser(1.7)
         visible minimum width
            - 0.0133cm for solid style
            - 0.0399cm for double style
         as there are three border lines painted -->
    <xsl:template name="round-up-border-width">
        <xsl:param name="borderWidth" />
        <xsl:param name="multiplier" />

        <xsl:variable name="borderWidthByCentimeter">
            <xsl:call-template name="convert2cm">
                <xsl:with-param name="value" select="$borderWidth" />
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="minimalBorderWidth" select="0.0133 * $multiplier" />
        <xsl:choose>
            <xsl:when test="number($borderWidthByCentimeter) &lt; $minimalBorderWidth">
                <xsl:value-of select="$minimalBorderWidth" />
                <xsl:text>cm</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$borderWidthByCentimeter" />
                <xsl:text>cm</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- changing measure to cm -->
    <xsl:template name="convert2cm">
        <xsl:param name="value"/>
        <xsl:variable name="rounding-factor" select="10000"/>
        <xsl:variable name="centimeter-in-mm" select="10"/>
        <xsl:variable name="inch-in-mm" select="25.4"/>
        <xsl:variable name="point-in-mm" select="0.3527778"/>
        <xsl:variable name="dpi" select="111"/>
        <xsl:variable name="pixel-in-mm" select="$inch-in-mm div $dpi"/>
        <xsl:choose>
            <xsl:when test="contains($value, 'mm')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $centimeter-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:when test="contains($value, 'cm')">
                <xsl:value-of select="substring-before($value, 'cm')"/>
            </xsl:when>
            <xsl:when test="contains($value, 'in')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $centimeter-in-mm * $inch-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:when test="contains($value, 'pt')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $centimeter-in-mm * $point-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:when test="contains($value, 'px')">
                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $centimeter-in-mm * $pixel-in-mm)) div $rounding-factor"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$value"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- Maps fo:margin as well as fo:margin-top, fo:margin-bottom, fo:padding-left, fo:margin-right -->
    <!-- Maps fo:padding as well as fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
    <xsl:template match="@fo:line-height | @fo:width | @fo:margin | @fo:margin-top | @fo:margin-bottom |
            @fo:margin-left | @fo:margin-right | @fo:padding | @fo:padding-top | @fo:padding-bottom |
            @fo:padding-left | @fo:padding-right | @fo:min-width | @fo:min-height | @fo:max-width | @fo:max-height |
            @style:width" mode="styleattr">
        <xsl:value-of select="local-name()"/><xsl:text>: </xsl:text>
        <xsl:choose>
            <!-- changing the distance measure: inch to in -->
            <xsl:when test="contains(., 'inch')"><xsl:value-of select="substring-before(.,'ch')"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>


    <!-- ALIGNMENT related properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="@fo:text-align" mode="styleattr">
        <!-- 'important' is necessary as table cell value alignment is decided by runtime over the valuetype
            Otherwise a table cell style-class would always be outnumbered by the run-time alignment value -->
        <xsl:value-of select="local-name()" /><xsl:text>: </xsl:text>
        <xsl:choose>
            <xsl:when test=".='start'"><xsl:text>left !important</xsl:text></xsl:when>
            <xsl:when test=".='end'"><xsl:text>right !important</xsl:text></xsl:when>
            <xsl:otherwise><xsl:value-of select="." /><xsl:text> !important</xsl:text></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:horizontal-pos" mode="styleattr">
        <xsl:choose>
            <!-- We can't support the others until we figure out pagination. -->
             <xsl:when test=".='left'">
                <xsl:text>text-align: left; margin-left: 0px; margin-right: auto; </xsl:text>
            </xsl:when>
            <xsl:when test=".='right'">
                <xsl:text>text-align: right; margin-left: auto; margin-right: 0px; </xsl:text>
            </xsl:when>
            <xsl:when test=".='center'">
                <xsl:text>text-align: center; margin-left: auto; margin-right: auto; </xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@draw:textarea-horizontal-align" mode="styleattr">
        <xsl:text>text-align: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:vertical-pos">
        <xsl:choose>
            <xsl:when test=".='from-top'">
                <xsl:text>vertical-align: top; </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>vertical-align: </xsl:text>
                <xsl:value-of select="."/>
                <xsl:text>; </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@draw:textarea-vertical-align | @style:vertical-align" mode="styleattr">
        <xsl:if test="not(.='justify') and not(.='automatic')">
            <xsl:text>vertical-align: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="@style:text-position" mode="styleattr">
        <xsl:variable name="thisValue" select="." />
        <xsl:text>vertical-align: </xsl:text>
        <xsl:choose>
            <xsl:when  test="contains($thisValue, ' ')">
                <xsl:value-of select="substring-before($thisValue,' ')" />
                <xsl:text>; </xsl:text>
                <xsl:text>font-size: </xsl:text>
                <xsl:value-of select="substring-after($thisValue,' ')" />
            </xsl:when>
            <xsl:otherwise><xsl:value-of select="$thisValue" /></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:ruby-position" mode="styleattr">
        <!-- only the value above (and inline) is supported by CSS -->
        <xsl:if test=".='above'">ruby-position: above; </xsl:if>
    </xsl:template>

    <xsl:template match="@table:align" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='left'"><xsl:text>float: right; </xsl:text></xsl:when>
            <xsl:when test=".='right'"><xsl:text>float: left; </xsl:text></xsl:when>
            <xsl:otherwise><xsl:text>float: none; </xsl:text></xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@style:writing-mode" mode="styleattr">
        <xsl:choose>
            <xsl:when test="contains(., 'lr')"><xsl:text>direction: ltr; </xsl:text></xsl:when>
            <xsl:when test="contains(., 'rl')"><xsl:text>direction: rtl;</xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>

    <!-- TEXT rendering related properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="@style:shadow" mode="styleattr">
        <xsl:text>text-shadow: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:text-underline-style | @style:text-underline-type" mode="styleattr">
       <!-- CSS2 only has one type of underline. TODO: improve this when CSS3 is better supported. -->
         <xsl:if test="not(.='none')"><xsl:text>text-decoration: underline; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:text-line-through-style" mode="styleattr">
        <xsl:if test=".='solid'"><xsl:text>text-decoration: line-through; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:text-blinking" mode="styleattr">
        <xsl:if test=".='true'"><xsl:text>text-decoration: blink; </xsl:text></xsl:if>
    </xsl:template>


    <!-- Width & Height properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="@style:column-width | @fo:page-width" mode="styleattr">
        <xsl:text>width: </xsl:text>
        <xsl:choose>
            <!-- changing the distance measure: inch to in -->
            <xsl:when test="contains(., 'inch')"><xsl:value-of select="substring-before(.,'ch')"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

    <xsl:template match="@style:row-height | @style:min-row-height | @fo:page-height" mode="styleattr">
        <xsl:text>height: </xsl:text>
        <xsl:choose>
            <!-- changing the distance measure: inch to in -->
            <xsl:when test="contains(., 'inch')"><xsl:value-of select="substring-before(.,'ch')"/></xsl:when>
            <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
        </xsl:choose>
        <xsl:text>; </xsl:text>
    </xsl:template>

   <xsl:template match="@table:border-model" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='collapsing'"><xsl:text>border-collapse: collapse; </xsl:text></xsl:when>
            <xsl:when test=".='separating'"><xsl:text>border-collapse: separate; </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@fo:wrap-option" mode="styleattr">
        <xsl:if test=".='no-wrap'"><xsl:text>white-space: nowrap; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:wrap" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='left'"><xsl:text>float: right; </xsl:text></xsl:when>
            <xsl:when test=".='right'"><xsl:text>float: left; </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@draw:fill" mode="styleattr">
        <xsl:choose>
            <xsl:when test=".='none'">background-color: transparent; </xsl:when>
            <xsl:when test=".='solid'">
                <xsl:text>background-color: </xsl:text>
                <xsl:value-of select="../@draw:fill-color" />
                <xsl:text>; </xsl:text>
            </xsl:when>
            <xsl:when test=".='bitmap'">
                <xsl:variable name="thisName" select="../@draw:fill-image-name" />
                <xsl:variable name="thisImage"
                        select="$documentStyles/office:styles/draw:fill-image[@draw:name=$thisName][1]/@xlink:href" />
                <xsl:text>background-image: url('</xsl:text>
                <xsl:value-of select='concat($param_imgloc, $thisImage)' />
                <xsl:text>'); </xsl:text>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="@text:space-before" mode="styleattr">
        <!-- however, "display: marker" is not yet supported as of Firefox 3, so this doesn't really have an effect -->
        <xsl:text>marker-offset: </xsl:text><xsl:value-of select="." /><xsl:text>; </xsl:text>
    </xsl:template>


    <xsl:template match="@*" mode="styleattr">
        <!-- don't output anything for attributes we don't understand -->
    </xsl:template>

    <!-- waiting for CSS3 support; TODO: when the following is supported by firefox from CSS3, uncomment this block
    <xsl:template match="@style:text-outline" mode="styleattr">
        <xsl:if test=".='true'"><xsl:text>font-effect: outline; </xsl:text></xsl:if>
    </xsl:template>

    <xsl:template match="@style:font-relief" mode="styleattr">
        <xsl:choose>
        <xsl:when test=".='embossed'"><xsl:text>font-effect: emboss; </xsl:text></xsl:when>
        <xsl:when test=".='engraved'"><xsl:text>font-effect: engrave; </xsl:text></xsl:when>
        </xsl:choose>
    </xsl:template>
    - end of waiting for CSS3 support items -->

    <xsl:template match="style:background-image">
        <xsl:if test="count(node())>0">
            <xsl:text>background-image: url('</xsl:text>
            <xsl:value-of select="concat($param_imgloc, @xlink:href)"/>
            <xsl:text>'); </xsl:text>
            <xsl:choose>
                <xsl:when test="@style:repeat = 'repeat'"><xsl:text>background-repeat: repeat; </xsl:text></xsl:when>
                <xsl:otherwise><xsl:text>background-repeat: no-repeat; </xsl:text></xsl:otherwise>
            </xsl:choose>
        </xsl:if>
    </xsl:template>

    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- lists properties -->
    <xsl:template match="text:list-style">
        <xsl:for-each select="text:list-level-style-bullet">
            <xsl:text>&nl;.</xsl:text>
            <xsl:value-of select="concat(translate(../@style:name,'.,;: %()[]/\+','_____________'), '_', @text:level)" />
            <xsl:text> { </xsl:text>
            <xsl:choose>
                <xsl:when test="@text:bullet-char='•'"><!-- BULLET (U+2022) -->
                    <xsl:text>list-style-type: disc; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='●'"><!-- BLACK CIRCLE (U+25CF) -->
                    <xsl:text>list-style-type: disc; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='✔'"><!-- HEAVY CHECK MARK (U+2714) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-check.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='✗'"><!-- BALLOT X (U+2717) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-x.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='➔'"><!-- HEAVY WIDE-HEADED RIGHTWARDS ARROW (U+2794) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-arrow.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char='➢'"><!-- THREE-D TOP-LIGHTED RIGHTWARDS ARROWHEAD (U+27A2) -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-3d-arrow.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char=''"><!-- diamond ◆ -->
                    <xsl:text>list-style-image: url('chrome://odfview/content/bullets/bullet-diamond.gif'); </xsl:text>
                </xsl:when>
                <xsl:when test="@text:bullet-char=''"><!-- square ◼ -->
                    <xsl:text>list-style-type: square; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test='@text:bullet-char="●"'><!-- blank -->
                    <xsl:text>list-style-type: none; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:level mod 3 = 1"><!-- for uncommon bullets, use the basic ones based on level -->
                    <xsl:text>list-style-type: disc; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:level mod 3 = 2"><!-- for uncommon bullets, use the basic ones based on level -->
                    <xsl:text>list-style-type: circle; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:when test="@text:level mod 3 = 0"><!-- for uncommon bullets, use the basic ones based on level -->
                    <xsl:text>list-style-type: square; list-style-image: none; </xsl:text>
                </xsl:when>
                <xsl:otherwise><!-- (default) -->
                    <xsl:text>list-style-type: decimal; list-style-image: none; </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:apply-templates select="style:list-level-properties/@*" mode="styleattr" />
            <xsl:apply-templates select="style:text-properties/@*" mode="styleattr" />
            <xsl:text> }</xsl:text>
        </xsl:for-each>

        <xsl:for-each select="text:list-level-style-image">
            <xsl:text>&nl;.</xsl:text>
            <xsl:value-of select="concat(translate(../@style:name,'.,;: %()[]/\+','_____________'), '_', @text:level)" />
            <xsl:text> { </xsl:text>
            <xsl:if test="@xlink:href">
                <xsl:text>list-style-image: url('</xsl:text>
                <xsl:value-of select="concat($param_imgloc, @xlink:href)" />
                <xsl:text>'); </xsl:text>
            </xsl:if>
            <xsl:text>}</xsl:text>
        </xsl:for-each>

        <xsl:for-each select="text:list-level-style-number">
            <xsl:text>&nl;.</xsl:text>
            <xsl:value-of select="concat(translate(../@style:name,'.,;: %()[]/\+','_____________'), '_', @text:level)" />
            <xsl:text> { list-style-type: </xsl:text>
            <xsl:choose>
                <xsl:when test="@style:num-format='1' and @style:num-prefix='0'">decimal-leading-zero</xsl:when>
                <xsl:when test="@style:num-format='1'">decimal</xsl:when>
                <xsl:when test="@style:num-format='I'">upper-roman</xsl:when>
                <xsl:when test="@style:num-format='i'">lower-roman</xsl:when>
                <xsl:when test="@style:num-format='A'">upper-alpha</xsl:when>
                <xsl:when test="@style:num-format='a'">lower-alpha</xsl:when>
                <xsl:otherwise>decimal</xsl:otherwise>
            </xsl:choose>
            <xsl:text>; list-style-image: none; }</xsl:text>
        </xsl:for-each>
    </xsl:template>

<!-- STYLES: templates for generating most of the CSS declarations END - = - = - = - = - = - = - = - = - = - = - = - -->


<!-- COMMON Items for all mimetypes START - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - =-->

    <!-- define the output content -->
    <xsl:output
        method="xml"
        indent="yes"
        omit-xml-declaration="yes"
        media-type="application/xhtml+xml"
        doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
        encoding="ISO-8859-1" />

    <!-- preserve the spaces contained on all elements -->
    <xsl:preserve-space elements="*" />

    <!-- set by javascript at runtime -->
    <xsl:param name="param_baseuri" />
    <xsl:param name="param_imgloc" />
    <xsl:param name="file_name" />

    <!-- set mimetype values for comparison -->
    <xsl:variable name="odt-mime">application/vnd.oasis.opendocument.text</xsl:variable>
    <xsl:variable name="ods-mime">application/vnd.oasis.opendocument.spreadsheet</xsl:variable>
    <xsl:variable name="odp-mime">application/vnd.oasis.opendocument.presentation</xsl:variable>

    <!-- represents the presentation's body -->
    <xsl:variable name="documentContent" select="/office:document/office:document-content" />
    <xsl:variable name="documentStyles" select="/office:document/office:document-styles" />

<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

    <!-- start at the document root -->
    <xsl:template match="/office:document">
        <html><xsl:text>&nl;</xsl:text>
            <head><xsl:text>&nl;</xsl:text>
                <xsl:apply-templates select="office:document-meta" /><xsl:text>&nl;</xsl:text>
                <xsl:call-template name="process-all-styles" /><xsl:text>&nl;</xsl:text>
            </head><xsl:text>&nl;</xsl:text>
            <xsl:choose>
                <xsl:when test="$mimetype=$odp-mime">
                    <xsl:call-template name="odp-js" /><xsl:text>&nl;</xsl:text>
                </xsl:when>
                <xsl:when test="$mimetype=$ods-mime">
                    <xsl:call-template name="ods-js" /><xsl:text>&nl;</xsl:text>
                </xsl:when>
            </xsl:choose>
            <xsl:apply-templates select="office:document-content" /><xsl:text>&nl;</xsl:text>
        </html>
    </xsl:template>

<!-- This section of the transformation handles generation of metadata. - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="office:document-meta">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="office:meta">
        <xsl:comment> Metadata starts </xsl:comment><xsl:text>&nl;</xsl:text>
        <xsl:if test="not(dc:title)"> <!-- use the file name on the titlebar if there is not dc:title meta-tag -->
            <title><xsl:value-of select="$file_name" /></title><xsl:text>&nl;</xsl:text>
        </xsl:if>
        <xsl:apply-templates select="dc:title" mode="header" />
        <xsl:apply-templates select="dc:creator" mode="header" />
        <xsl:apply-templates select="dc:date" mode="header" />
        <xsl:apply-templates select="dc:language" mode="header" />
        <xsl:apply-templates select="dc:description" mode="header" />
        <xsl:apply-templates select="meta:keyword" mode="header" />
        <xsl:apply-templates select="meta:generator" mode="header" />
        <xsl:comment> Metadata ends </xsl:comment><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="dc:title" mode="header">
        <title><xsl:apply-templates /></title><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="dc:language" mode="header">
        <meta http-equiv="content-language" content="{current()}" /><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="dc:creator" mode="header">
        <meta name="author" content="{current()}" /><xsl:text>&nl;</xsl:text>
        <meta name="DC.creator" content="{current()}" /><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="dc:description" mode="header">
        <meta name="description" content="{current()}" /><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="dc:date" mode="header">
        <meta name="revised" content="{current()}" /><xsl:text>&nl;</xsl:text>
        <meta name="DC.date" content="{current()}" /><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="meta:keyword" mode="header">
        <meta name="keywords" content="{current()}" /><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="meta:generator" mode="header">
        <meta name="generator" content="{current()}" /><xsl:text>&nl;</xsl:text>
    </xsl:template>

<!-- This section of the transformation handles the generation of the CSS. - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template name="process-all-styles">
        <xsl:element name="style">
            <xsl:attribute name="type">text/css</xsl:attribute>
            <!-- /* li:before { display: marker; } */ not yet supported in Firefox 3 -->
            p, div { margin: 0px; padding: 0px; } /* ODF paragraphs, by default, don't have any line spacing. (use div to represent text:p) */
            a[href] { color: blue; text-decoration: underline; } /* put a default link style in, so that links are evident */
            h1, h2, h3, h4, h5, h6 { clear: both; }
            * { z-index: 1; word-wrap: break-word; line-height: 100%; }
            <xsl:if test="$mimetype!=$odt-mime">
                a[onclick] { color: blue; text-decoration: underline; cursor: pointer; }
            </xsl:if>
            <xsl:choose>
                <xsl:when test="$mimetype=$ods-mime">td, th { vertical-align: top; font-size: 10pt; }
                .toolTipMarker { color:red;float:right; }
                div.tooltipContents { display: none; white-space: normal; padding: 5px; margin: 10px; z-index: 100; }
                td.tooltip:hover { position: relative; }
                td.tooltip:hover div.tooltipContents { display: block; position: absolute; }
                </xsl:when>
                <xsl:otherwise>td, th { vertical-align: top; font-size: 12pt; }</xsl:otherwise>
            </xsl:choose>
            /* Document styles start */
            <xsl:apply-templates select="office:document-styles/office:styles" />
            /* Document styles end */
            /* Automatic styles start */
            <xsl:apply-templates select="office:document-styles/office:automatic-styles" />
            <xsl:apply-templates select="office:document-content/office:automatic-styles" />
            /* Automatic styles end */&nl;
            <xsl:call-template name="toc-styles" />
        </xsl:element>
    </xsl:template>

    <xsl:template match="office:document-styles/office:automatic-styles">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="office:document-content/office:automatic-styles">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="office:document-styles/office:styles">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template name="toc-styles">
        <xsl:apply-templates select="//text:table-of-content" mode="toc-styles" />
    </xsl:template>

    <xsl:template match="text:table-of-content" mode="toc-styles">
        /* ToC styles start */&nl;.toc_outline a { text-decoration: none; }
        <xsl:apply-templates select="//text:h" mode="toc-styles" />
        /* ToC styles end */
    </xsl:template>

    <xsl:template match="text:h" mode="toc-styles">
        <xsl:if test="@text:outline-level">
            <xsl:text>&nl;.toc_outline_level_</xsl:text><xsl:value-of select="@text:outline-level" />
            <xsl:text>_</xsl:text><xsl:value-of select="@text:style-name" />
            <xsl:text> { margin-left: </xsl:text><xsl:value-of select="@text:outline-level*0.5" />
            <xsl:text>cm; }</xsl:text>
        </xsl:if>
    </xsl:template>

    <xsl:template match="*" mode="toc-styles" />


    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- templates for generating a new ToC (instead of parsing the document's ToC) -->
    <xsl:template match="text:table-of-content">
        <xsl:comment> Table of Contents begins </xsl:comment>
        <div class="toc" style="width:100%; background-color:#D8D8D8; font-weight:bold;"><xsl:text>&nl;</xsl:text>
            <a name="toc" /><xsl:apply-templates select="text:index-body/text:index-title" />
            <xsl:apply-templates select="//text:h" mode="toc" />
        </div><xsl:comment> Table of Contents ends </xsl:comment><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <xsl:template match="text:h" mode="toc">
        <xsl:element name="p">
            <xsl:attribute name="class">
                <xsl:text>toc_outline toc_outline_level_</xsl:text>
                <xsl:choose>
                    <xsl:when test="@text:outline-level">
                        <xsl:value-of select="@text:outline-level" />
                    </xsl:when>
                    <!-- ODF spec says that when unspecified the outline level should be considered to be 1. -->
                    <xsl:otherwise>1</xsl:otherwise>
                </xsl:choose>
                <xsl:text>_</xsl:text><xsl:value-of select="@text:style-name" />
            </xsl:attribute>
            <a href="#{generate-id()}"><xsl:value-of select="." /></a>
        </xsl:element><xsl:text>&nl;</xsl:text>
    </xsl:template>


<!-- This section of the transformation handles the generation of the body contents. - - - - - - - - - - - - - - - - -->

    <xsl:template match="office:document-content">
        <!-- approximation as attribute belongs to a page style, which won't work in XHTML -->
        <xsl:variable name="pageProperties" select="$documentContent/office:automatic-styles/style:page-layout[1]/style:page-layout-properties"/>

        <xsl:element name="body">
            <!-- direction of text flow -->
            <xsl:variable name="writingMode" select="$pageProperties/@style:writing-mode"/>
            <xsl:if test="$writingMode">
                <xsl:choose>
                    <xsl:when test="contains($writingMode, 'lr')">
                        <xsl:attribute name="dir">ltr</xsl:attribute>
                    </xsl:when>
                    <xsl:when test="contains($writingMode, 'rl')">
                        <xsl:attribute name="dir">rtl</xsl:attribute>
                    </xsl:when>
                </xsl:choose>
            </xsl:if>

            <!-- adapt page size -->
            <xsl:variable name="pageWidth" select="$pageProperties/@fo:page-width"/>

            <!-- multiple backgroundimages for different page styles (never used in html) -->
            <xsl:variable name="backgroundImage" select="$pageProperties/style:background-image"/>

            <!-- page margins & background image  -->
            <xsl:if test="$pageWidth or $pageProperties/@fo:* or $backgroundImage/@xlink:href">
                <xsl:attribute name="style">
                    <xsl:if test="$pageWidth">
                         <xsl:text>max-width:</xsl:text><xsl:value-of select="$pageWidth"/><xsl:text>;</xsl:text>
                    </xsl:if>
                    <xsl:if test="$pageProperties/@fo:* or $backgroundImage/@xlink:href">
                        <xsl:apply-templates select="$pageProperties/@fo:*"/>
                        <xsl:if test="$backgroundImage/@xlink:href">
                            <xsl:text>background-image:url(</xsl:text>
                            <xsl:call-template name="create-href">
                                <xsl:with-param name="href" select="$backgroundImage/@xlink:href"/>
                            </xsl:call-template>
                            <xsl:text>); </xsl:text>

                            <xsl:if test="$backgroundImage/@style:repeat">
                                <xsl:choose>
                                    <xsl:when test="$backgroundImage/@style:repeat = 'no-repeat'">
                                        <xsl:text>background-repeat: no-repeat; </xsl:text>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:text>background-repeat: repeat; </xsl:text>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:if>
                            <xsl:if test="$backgroundImage/@style:position">
                                <xsl:text>background-position: </xsl:text>
                                <xsl:value-of select="$backgroundImage/@style:position"/>
                                <xsl:text>; </xsl:text>
                            </xsl:if>
                        </xsl:if>
                    </xsl:if>
                </xsl:attribute>
            </xsl:if>

            <!-- evaluate the document's content -->
            <xsl:if test="$mimetype=$odp-mime">
                <xsl:attribute name="onload">showPage(1)</xsl:attribute><xsl:text>&nl;</xsl:text>
                <div style="text-align: right;" id="linkAll">
                <xsl:text> &nbsp; | &nbsp; </xsl:text>
                <a onclick="showAll()" style="font-family:Arial;font-size:10pt;">Show All Slides</a>
                <xsl:text> &nbsp; | &nbsp; &nl;</xsl:text>
                </div>
                <xsl:apply-templates select="office:body/office:presentation" />
            </xsl:if>
            <xsl:if test="$mimetype=$odt-mime">
                <xsl:apply-templates select="office:body/office:text" />
                <xsl:call-template name="add-footnote-bodies" />
            </xsl:if>
            <xsl:if test="$mimetype=$ods-mime">
                <xsl:variable name="oooViewSettings"
select="/office:document/office:document-settings/office:settings/config:config-item-set[@config:name='ooo:view-settings'][1]" />
                <xsl:variable name="activeSheet"
select="$oooViewSettings/config:config-item-map-indexed/config:config-item-map-entry/config:config-item[@config:name='ActiveTable'][1]" />
                <xsl:attribute name="onload">
                    <xsl:text>showPage('</xsl:text><xsl:value-of select="$activeSheet" /><xsl:text>')</xsl:text>
                </xsl:attribute><xsl:text>&nl;</xsl:text>
                <xsl:text> | </xsl:text>
                <xsl:for-each select="office:body/office:spreadsheet/table:table">
                    <xsl:element name="a">
                        <xsl:attribute name="onclick">
                            <xsl:text>showPage('</xsl:text><xsl:value-of select="@table:name" /><xsl:text>')</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="id">
                            <xsl:text>link</xsl:text><xsl:value-of select="@table:name" />
                        </xsl:attribute>
                        <xsl:attribute name="name"><xsl:text>sheetlink</xsl:text></xsl:attribute>
                        <xsl:value-of select="@table:name" />
                    </xsl:element>
                    <xsl:text> | </xsl:text>
                </xsl:for-each>
                <xsl:apply-templates select="office:body/office:spreadsheet" />
            </xsl:if>
            <xsl:text>&nl;</xsl:text>
        </xsl:element>
    </xsl:template>


<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

<!-- This section of the transformation handles the true content elements in the content.xml file
     (The order of the tags is based on the order on the OpenDocument specification.)

     /* templates for creating the body */
-->

<!-- HEADINGS, PARAGRAPHS AND BASIC TEXT STRUCTURE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- template for converting the header tag <h> -->
    <xsl:template match="text:h">
        <xsl:choose>
            <xsl:when test="@text:outline-level >= 6">
                <xsl:element name="h6">
                    <xsl:if test="@text:style-name">
                        <xsl:attribute name="class">
                            <xsl:call-template name="callClassInheritance">
                                <xsl:with-param name="paramValue"><xsl:value-of select="@text:style-name" /></xsl:with-param>
                            </xsl:call-template>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:apply-templates />
                </xsl:element>
            </xsl:when>
            <xsl:otherwise>
                <xsl:element name="{concat('h', @text:outline-level)}">
                    <xsl:if test="@text:style-name">
                        <xsl:attribute name="class">
                            <xsl:call-template name="callClassInheritance">
                                <xsl:with-param name="paramValue"><xsl:value-of select="@text:style-name" /></xsl:with-param>
                            </xsl:call-template>
                        </xsl:attribute>
                    </xsl:if>
                    <a name="{generate-id()}" /> <!-- For the table-of-contents bookmarks -->
                    <a href="#toc" style="text-decoration:inherit; color:inherit" title="Return to Table of Contents">
                        <xsl:apply-templates />
                    </a>
                </xsl:element>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:text>&nl;</xsl:text>
    </xsl:template>

    <!-- template for recursive converting the paragraph tag <p> -->
    <xsl:template match="text:p">
        <xsl:param name="tempParam" />
        <xsl:text>&nl;</xsl:text>
        <xsl:choose>
            <xsl:when test="count(node())=0"><br /><!-- empty p tag yields a line break --></xsl:when>
            <xsl:otherwise>
                <!-- According to the HTML4 spec, you are not allowed to nest other block-level elements
                    (<div>, <ul>, other <p>, etc) inside a <p> without invalidating your HTML. -->
                <xsl:choose>
                    <xsl:when test="parent::text:list-item">
                        <xsl:element name="span">
                            <xsl:if test="@text:style-name">
                                <xsl:attribute name="class">
                                    <xsl:call-template name="callClassInheritance">
                                        <xsl:with-param name="paramValue"><xsl:value-of select="@text:style-name" /></xsl:with-param>
                                    </xsl:call-template>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:apply-templates>
                                <xsl:with-param name="tempParam" select="$tempParam" />
                            </xsl:apply-templates>
                        </xsl:element>
                    </xsl:when>
                    <xsl:when test="parent::table:table-cell">
                        <xsl:element name="div">
                            <xsl:if test="$mimetype != $ods-mime">
                                <xsl:if test="$tempParam">
                                    <xsl:attribute name="style">width: <xsl:value-of select="$tempParam" /></xsl:attribute>
                                </xsl:if>
                            </xsl:if>
                            <xsl:if test="@text:style-name">
                                <xsl:attribute name="class">
                                    <xsl:call-template name="callClassInheritance">
                                        <xsl:with-param name="paramValue"><xsl:value-of select="@text:style-name" /></xsl:with-param>
                                    </xsl:call-template>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:apply-templates>
                                <xsl:with-param name="tempParam" select="$tempParam" />
                            </xsl:apply-templates>
                        </xsl:element>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:element name="div">
                            <xsl:if test="@text:style-name">
                                <xsl:attribute name="class">
                                    <xsl:call-template name="callClassInheritance">
                                        <xsl:with-param name="paramValue"><xsl:value-of select="@text:style-name" /></xsl:with-param>
                                    </xsl:call-template>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:apply-templates>
                                <xsl:with-param name="tempParam" select="$tempParam" />
                            </xsl:apply-templates>
                        </xsl:element>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:text>&nl;</xsl:text>
    </xsl:template>

    <!-- templates for converting lists (uses recursion to handle lists in lists)-->
    <xsl:template match="text:list">
        <xsl:if test="not(../self::text:list)">
            <ul class="{concat(translate(@text:style-name,'.,;: %()[]/\+','_____________'), '_1')}">
                <xsl:text>&nl;</xsl:text>
                <xsl:call-template name="convertList">
                    <xsl:with-param name="level">1</xsl:with-param>
                    <xsl:with-param name="style_name">
                        <xsl:value-of select="@text:style-name" />
                    </xsl:with-param>
                </xsl:call-template>
            </ul>
        </xsl:if>
    </xsl:template>
    <xsl:template name="convertList">
        <xsl:param name="level" />
        <xsl:param name="style_name" />
        <xsl:for-each select="text:list-item">
            <xsl:element name="li">
                <xsl:if test="child::node()[1][self::text:list]">
                    <!-- if the first child of the <li> is a list, do not display the bullet for this <li> -->
                    <xsl:attribute name="style">list-style-type:none;</xsl:attribute>
                </xsl:if>
                <xsl:element name="span"> <!-- done to accommodate cases when color of bullet is different from text -->
                    <xsl:if test="$mimetype=$odp-mime">
                        <xsl:attribute name="class">
                            <xsl:call-template name="callClassInheritance">
                                <xsl:with-param name="paramValue"><xsl:value-of select="ancestor::draw:frame[1]/@presentation:style-name" /></xsl:with-param>
                            </xsl:call-template>
                            <xsl:if test="not(child::node()[1][self::text:list])"><xsl:text> </xsl:text>
                                <xsl:call-template name="callClassInheritance">
                                    <xsl:with-param name="paramValue"><xsl:value-of select="ancestor::draw:frame[1]/@draw:text-style-name" /></xsl:with-param>
                                </xsl:call-template>
                            </xsl:if>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:for-each select="*">
                        <xsl:choose>
                            <xsl:when test="self::text:list">
                                <ul class="{concat(translate($style_name,'.,;: %()[]/\+','_____________'), '_', ($level + 1))}">
                                    <xsl:call-template name="convertList">
                                        <xsl:with-param name="level">
                                            <xsl:value-of select="$level + 1" />
                                        </xsl:with-param>
                                        <xsl:with-param name="style_name">
                                            <xsl:value-of select="$style_name" />
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </ul>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:apply-templates select="." />
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:for-each>
                </xsl:element>
            </xsl:element>
        </xsl:for-each>
    </xsl:template>

    <!-- templates for when the document has tracked changes on -->
    <xsl:template match="text:tracked-changes">
        <xsl:comment> Document has track-changes on </xsl:comment>
    </xsl:template>
    <xsl:template match="text:change">
        <xsl:variable name="id" select="@text:change-id" />
        <xsl:variable name="change" select="//text:changed-region[@text:id=$id]" />
        <!-- <del><xsl:value-of select="$change" /></del> -->
        <xsl:element name="del">
            <xsl:attribute name="datetime">
                <xsl:value-of select="$change//dc:date" />
            </xsl:attribute>
            <xsl:value-of select="$change//text:p" />
        </xsl:element>
    </xsl:template>


<!-- PARAGRAPH ELEMENTS CONTENT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- non-unicode display for ‘, ’, “, ”, – -->
    <xsl:template match="text()">
        <xsl:value-of
            select="translate(translate(translate(translate(translate(.,'–','&#45;'),'“','&quot;'),'”','&quot;'),'‘','&#145;'),'’','&#146;')" />
    </xsl:template>

    <!-- templates for converting the space tag -->
    <xsl:template match="text:s">
        <xsl:call-template name="preserve_spaces">
            <xsl:with-param name="count">
                <xsl:value-of select="@text:c" />
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="preserve_spaces">
        <xsl:param name="count" />
        <xsl:if test="$count &gt; 0">
            <xsl:text>&nbsp;</xsl:text>
            <xsl:call-template name="preserve_spaces">
                <xsl:with-param name="count">
                    <xsl:value-of select="$count - 1" />
                </xsl:with-param>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>

    <!-- template for converting the tab tag (replaced by 8 spaces since the tab char seems to be useless in html) -->
    <xsl:template match="text:tab">
        <xsl:text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
    </xsl:template>

    <!-- template for converting a line_break -->
    <xsl:template match="text:line-break">
        <br />
    </xsl:template>

    <!-- template for converting (Attributed Text) a span tag (contents are recursively parsed for templates) -->
    <xsl:template match="text:span">
        <xsl:param name="tempParam" />
        <xsl:element name="span">
            <xsl:if test="@text:style-name">
                <xsl:attribute name="class">
                    <xsl:call-template name="callClassInheritance">
                        <xsl:with-param name="paramValue"><xsl:value-of select="@text:style-name" /></xsl:with-param>
                    </xsl:call-template>
                </xsl:attribute>
            </xsl:if>
            <xsl:apply-templates>
                <xsl:with-param name="tempParam" select="$tempParam" />
            </xsl:apply-templates>
        </xsl:element>
    </xsl:template>

    <!-- template for converting hyperlinks -->
    <xsl:template match="text:a">
        <a name="{@office:name}" title="{@office:title}" href="{@xlink:href}"><xsl:apply-templates /></a>
    </xsl:template>

    <!--
        <text:bookmark-start /> and <text:bookmark-end /> can be on non-wellformed boundaries.
        The quickest solution is to create an <a name=""></a> element.

        If you don't put in any content, it becomes an empty element, which will confuse browsers.
        The right solution is to insert a zero-width non-breaking space (Unicode 0x200b) but this won't work
        with IE, so we use this instead.
    -->
    <xsl:template match="text:bookmark-start|text:bookmark">
        <a name="{@text:name}">
            <span style="font-size: 0px">
                <xsl:text> </xsl:text>
            </span>
        </a>
    </xsl:template>

    <!-- templates for the Note Element -->
    <xsl:template match="text:note">
        <xsl:variable name="footnote-id" select="text:note-citation" />
        <a href="#footnote-{$footnote-id}">
            <sup>
                <xsl:value-of select="$footnote-id" />
            </sup>
        </a>
    </xsl:template>

    <xsl:template name="add-footnote-bodies">
        <xsl:apply-templates select="//text:note" mode="add-footnote-bodies" />
    </xsl:template>

    <xsl:template match="text:note" mode="add-footnote-bodies">
        <xsl:variable name="footnote-id" select="text:note-citation" />
        <p><a name="footnote-{$footnote-id}"><sup><xsl:value-of select="$footnote-id" /></sup>:</a></p>
        <xsl:apply-templates select="text:note-body/*" />
    </xsl:template>

    <xsl:template match="text:note-body" />


<!-- TABLES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- template for converting the table tag -->

    <xsl:template match="table:table">
        <xsl:text>&nl;</xsl:text>
        <xsl:element name="table">
            <xsl:attribute name="id"><xsl:value-of select="@table:name" /></xsl:attribute>
            <xsl:if test="$mimetype=$ods-mime"><xsl:attribute name="name">spreadSheet</xsl:attribute></xsl:if>
            <xsl:variable name="tableName" select="@table:name" />
<xsl:variable name="tableAlign"
select="$documentContent/office:automatic-styles/style:style[@style:name=$tableName]/style:table-properties/@table:align" />
            <xsl:if test="$tableAlign"><xsl:attribute name="align"><xsl:value-of select="$tableAlign" /></xsl:attribute></xsl:if>
            <xsl:attribute name="class">
                <xsl:call-template name="callClassInheritance">
                    <xsl:with-param name="paramValue"><xsl:value-of select="@table:style-name" /></xsl:with-param>
                </xsl:call-template>
            </xsl:attribute>
            <colgroup>
                <xsl:apply-templates select="table:table-column" />
            </colgroup>
            <xsl:if test="table:table-header-rows/table:table-row">
                <thead>
                    <xsl:apply-templates select="table:table-header-rows/table:table-row" />
                </thead>
            </xsl:if>
            <tbody>
                <xsl:apply-templates select="table:table-row" />
            </tbody>
        </xsl:element>
    </xsl:template>

    <xsl:template match="table:table-column">
        <xsl:element name="col">
            <xsl:if test="@table:number-columns-repeated">
                <xsl:attribute name="span">
                    <xsl:value-of select="@table:number-columns-repeated" />
                </xsl:attribute>
            </xsl:if>
            <xsl:if test="@table:style-name">
                <xsl:attribute name="class">
                    <xsl:call-template name="callClassInheritance">
                        <xsl:with-param name="paramValue">
                            <xsl:value-of select="translate(@table:style-name,'.,;: %()[]/\+','_____________')" />
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:attribute>
            </xsl:if>
        </xsl:element>
    </xsl:template>

    <xsl:template match="table:table-row">
        <xsl:element name="tr">
            <xsl:apply-templates select="table:table-cell" />
        </xsl:element>
    </xsl:template>

    <xsl:template match="table:table-cell">
        <xsl:variable name="n">
            <xsl:choose>
                <xsl:when test="@table:number-columns-repeated != 0">
                    <xsl:value-of select="@table:number-columns-repeated" />
                </xsl:when>
                <xsl:otherwise>1</xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="process-table-cell">
            <xsl:with-param name="n" select="$n" />
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="process-table-cell">
        <xsl:param name="n" />
        <xsl:if test="$n != 0">
            <xsl:element name="td">
                <xsl:if test="@table:style-name">
                    <xsl:attribute name="class">
                        <xsl:call-template name="callClassInheritance">
                            <xsl:with-param name="paramValue">
                                <xsl:value-of select="translate(@table:style-name,'.,;: %()[]/\+','_____________')" />
                            </xsl:with-param>
                        </xsl:call-template>
                        <xsl:if test="child::node()[1][self::office:annotation]">
                            <xsl:text> tooltip</xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                </xsl:if>
                <xsl:if test="not(@table:style-name) and child::node()[1][self::office:annotation]">
                    <xsl:attribute name="class">
                        <xsl:text>tooltip</xsl:text>
                    </xsl:attribute>
                </xsl:if>
                <xsl:if test="@table:number-columns-spanned">
                    <xsl:attribute name="colspan">
                        <xsl:value-of select="@table:number-columns-spanned" />
                    </xsl:attribute>
                </xsl:if>
                <xsl:if test="@table:number-rows-spanned">
                    <xsl:attribute name="rowspan">
                        <xsl:value-of select="@table:number-rows-spanned" />
                    </xsl:attribute>
                </xsl:if>
                <xsl:variable name="precSibs" select="count(preceding-sibling::table:covered-table-cell)"/>
                <xsl:variable name="colNumber" select="position() + $precSibs"/>
                <xsl:variable name="colStyleMain" select="ancestor::table:table[1]/table:table-column[1]/@table:style-name" />
                <xsl:variable name="colStyle" select="ancestor::table:table[1]/table:table-column[$colNumber]/@table:style-name" />
<xsl:variable name="thisWidth"
select="$documentContent/office:automatic-styles/style:style[@style:name=$colStyle][1]/style:table-column-properties/@style:column-width" />
<xsl:variable name="thisMainWidth"
select="$documentContent/office:automatic-styles/style:style[@style:name=$colStyleMain][1]/style:table-column-properties/@style:column-width" />
                <xsl:apply-templates>
                    <xsl:with-param name="tempParam">
                        <xsl:choose>
                            <xsl:when test="$thisWidth"><xsl:value-of select="$thisWidth" /></xsl:when>
                            <xsl:otherwise><xsl:value-of select="$thisMainWidth" /></xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:apply-templates>
                <!-- put a single space for an empty cell
                    (so that borders will still be drawn; esp. on firefox versions lower than 3.0) -->
                <xsl:if test="count(node())=0">&nbsp;</xsl:if>
            </xsl:element>
            <xsl:call-template name="process-table-cell">
                <xsl:with-param name="n" select="$n - 1" />
            </xsl:call-template>
        </xsl:if>
    </xsl:template>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- helper templates to resolve class inheritance (Use Multiple Class Names and Combined Class Selectors) -->

    <xsl:template name="callClassInheritance">
        <xsl:param name="paramValue" />
        <xsl:call-template name="classInheritance">
            <xsl:with-param name="styleName"><xsl:value-of select="$paramValue" /></xsl:with-param>
            <xsl:with-param name="class"><xsl:value-of select="translate($paramValue,'.,;: %()[]/\+','_____________')" /></xsl:with-param>
            <xsl:with-param name="separator"><xsl:text> </xsl:text></xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="classInheritance">
        <xsl:param name="styleName" />
        <xsl:param name="class" />
        <xsl:param name="separator" />
        <xsl:variable name="content-auto" select="$documentContent/office:automatic-styles/style:style[@style:name=$styleName][1]/@style:parent-style-name" />
        <xsl:variable name="styles-auto" select="$documentStyles/office:automatic-styles/style:style[@style:name=$styleName][1]/@style:parent-style-name" />
        <xsl:variable name="styles-styles" select="$documentStyles/office:styles/style:style[@style:name=$styleName][1]/@style:parent-style-name" />
        <xsl:choose>
            <xsl:when test="count($content-auto) > 0">
                <xsl:call-template name="classInheritance">
                    <xsl:with-param name="styleName">
                        <xsl:value-of select="$content-auto" />
                    </xsl:with-param>
                    <xsl:with-param name="class">
                        <xsl:value-of select="translate($content-auto,'.,;: %()[]/\+','_____________')" />
                        <xsl:value-of select="$separator" />
                        <xsl:value-of select="$class" />
                    </xsl:with-param>
                    <xsl:with-param name="separator">
                        <xsl:value-of select="$separator" />
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="count($styles-auto) > 0">
                <xsl:call-template name="classInheritance">
                    <xsl:with-param name="styleName">
                        <xsl:value-of select="$styles-auto" />
                    </xsl:with-param>
                    <xsl:with-param name="class">
                        <xsl:value-of select="translate($styles-auto,'.,;: %()[]/\+','_____________')" />
                        <xsl:value-of select="$separator" />
                        <xsl:value-of select="$class" />
                    </xsl:with-param>
                    <xsl:with-param name="separator">
                        <xsl:value-of select="$separator" />
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="count($styles-styles) > 0">
                <xsl:call-template name="classInheritance">
                    <xsl:with-param name="styleName">
                        <xsl:value-of select="$styles-styles" />
                    </xsl:with-param>
                    <xsl:with-param name="class">
                        <xsl:value-of select="translate($styles-styles,'.,;: %()[]/\+','_____________')" />
                        <xsl:value-of select="$separator" />
                        <xsl:value-of select="$class" />
                    </xsl:with-param>
                    <xsl:with-param name="separator">
                        <xsl:value-of select="$separator" />
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$class" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

<!-- SHAPES & OBJECTS -->

    <xsl:template match="draw:circle | draw:polygon | draw:regular-polygon | draw:ellipse | draw:custom-shape |
            draw:text | draw:object">
        <!-- even if shapes cannot be drawn, at least show the text inside -->
        <xsl:element name="div">
            <xsl:attribute name="style">
                <xsl:if test="@svg:width">width: <xsl:value-of select="@svg:width" />; </xsl:if>
                <xsl:if test="@svg:height">height: <xsl:value-of select="@svg:height" />; </xsl:if>
                <xsl:if test="@svg:x">position: absolute; left: <xsl:value-of select="@svg:x" />; </xsl:if>
                <xsl:if test="@svg:y">top: <xsl:value-of select="@svg:y" />; </xsl:if>
                <xsl:if test="@draw:z-index">z-index: <xsl:value-of select="@draw:z-index" />; </xsl:if>
                <xsl:if test="not(@draw:z-index)">z-index: 5; </xsl:if>
            </xsl:attribute>
            <xsl:apply-templates />
        </xsl:element>
    </xsl:template>

    <xsl:template match="draw:line | draw:polyline | draw:path | draw:g | draw:page-thumbnail | draw:measure |
            draw:caption | draw:connector | draw:control | dr3d:scene | draw:custom-shape | draw:text | draw:object">
        <!-- do nothing for now for shapes that we cannot draw -->
    </xsl:template>

<!-- COMMON Items for all mimetypes END - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = =-->


<!-- COMMON Items for all text and spreadsheet documents START - = - = - = - = - = - = - = - = - = - = - = - = - = - -->

<!-- GRAPHIC CONTENT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- add the drawing element's properties in the inline CSS for this object -->
    <xsl:template match="draw:frame/draw:image | draw:frame/draw:text-box" mode="attribs">
        <xsl:if test="../@svg:width">width: <xsl:value-of select="../@svg:width" />; </xsl:if>
        <xsl:if test="../@svg:height">height: <xsl:value-of select="../@svg:height" />; </xsl:if>
        <xsl:if test="../@svg:x">position: relative; left: <xsl:value-of select="../@svg:x" />; </xsl:if>
        <xsl:if test="../@svg:y">top: <xsl:value-of select="../@svg:y" />; </xsl:if>
        <xsl:if test="../@fo:min-width">min-width: <xsl:value-of select="../@fo:min-width" />; </xsl:if>
        <xsl:if test="../@fo:min-height">min-height: <xsl:value-of select="../@fo:min-height" />; </xsl:if>
        <xsl:if test="../@fo:max-width">max-width: <xsl:value-of select="../@fo:max-width" />; </xsl:if>
        <xsl:if test="../@fo:max-height">max-height: <xsl:value-of select="../@fo:max-height" />; </xsl:if>
        <xsl:if test="../@draw:z-index">z-index: <xsl:value-of select="../@draw:z-index" />; </xsl:if>
    </xsl:template>

    <!-- IMAGES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <!-- template for displaying images: first check where the image is anchored -->
    <xsl:template match="draw:frame/draw:image">
        <xsl:choose>
            <xsl:when test="../@text:anchor-type='as-char'">
                <xsl:apply-templates select="." mode="drawing" />
            </xsl:when>
            <xsl:when test="../@text:anchor-type='char'">
                <xsl:element name="span">
                    <xsl:attribute name="class">
                        <xsl:call-template name="classInheritance">
                            <xsl:with-param name="styleName">
                                <xsl:if test="../@draw:style-name"><xsl:value-of select="../@draw:style-name" /></xsl:if>
                            </xsl:with-param>
                            <xsl:with-param name="class">
                                <xsl:if test="../@draw:style-name"><xsl:value-of select="translate(../@draw:style-name,'.','_')" /></xsl:if>
                            </xsl:with-param>
                            <xsl:with-param name="separator"><xsl:text> </xsl:text></xsl:with-param>
                        </xsl:call-template>
                    </xsl:attribute>
                    <xsl:attribute name="style">
                        <xsl:apply-templates select="." mode="attribs" />
                    </xsl:attribute>
                <xsl:apply-templates select="." mode="drawing" />
                <xsl:apply-templates />
                </xsl:element><xsl:text>&nl;</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:element name="div">
                    <xsl:attribute name="class">
                        <xsl:call-template name="classInheritance">
                            <xsl:with-param name="styleName">
                                <xsl:if test="../@draw:style-name"><xsl:value-of select="../@draw:style-name" /></xsl:if>
                            </xsl:with-param>
                            <xsl:with-param name="class">
                                <xsl:if test="../@draw:style-name"><xsl:value-of select="translate(../@draw:style-name,'.','_')" /></xsl:if>
                            </xsl:with-param>
                            <xsl:with-param name="separator"><xsl:text> </xsl:text></xsl:with-param>
                        </xsl:call-template>
                    </xsl:attribute>
                    <xsl:attribute name="style">
                        <xsl:apply-templates select="." mode="attribs" />
                    </xsl:attribute>
                <xsl:apply-templates select="." mode="drawing" />
                <xsl:apply-templates />
                </xsl:element><xsl:text>&nl;</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- template for displaying the actual image -->
    <xsl:template match="draw:frame/draw:image" mode="drawing">
        <xsl:element name="img">
            <xsl:attribute name="class">
                <xsl:value-of select="translate(../@draw:style-name,'.','_')" />
            </xsl:attribute>
            <xsl:attribute name="style">
                <xsl:if test="../@svg:width">width: <xsl:value-of select="../@svg:width" />; </xsl:if>
                <xsl:if test="../@svg:height">height: <xsl:value-of select="../@svg:height" />; </xsl:if>
            </xsl:attribute>
            <xsl:if test="../svg:desc"><xsl:attribute name="alt">
                <xsl:value-of select="../svg:desc" />
            </xsl:attribute></xsl:if>
            <xsl:attribute name="src">
              <xsl:value-of select="concat($param_imgloc, @xlink:href)" />
            </xsl:attribute>
        </xsl:element>
    </xsl:template>

    <xsl:template match="svg:desc" />

    <!-- TEXT BOXES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <xsl:template match="draw:frame/draw:text-box">
        <xsl:element name="div">
            <xsl:attribute name="class">
                <xsl:call-template name="classInheritance">
                    <xsl:with-param name="styleName">
                        <xsl:if test="../@draw:style-name"><xsl:value-of select="../@draw:style-name" /></xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="class">
                        <xsl:if test="../@draw:style-name"><xsl:value-of select="translate(../@draw:style-name,'.','_')" /></xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="separator"><xsl:text> </xsl:text></xsl:with-param>
                </xsl:call-template>
            </xsl:attribute>
            <xsl:attribute name="style">
                <xsl:apply-templates select="." mode="attribs" />
                <xsl:if test="../@draw:z-index">z-index: <xsl:value-of select="../@draw:z-index" />; </xsl:if>
            </xsl:attribute>
            <xsl:apply-templates />
        </xsl:element><xsl:text>&nl;</xsl:text>
    </xsl:template>

    <!-- SHAPES: Rectangle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <xsl:template match="draw:rect">
        <xsl:element name="div">
            <xsl:attribute name="class">
                <xsl:if test="@draw:style-name">
                    <xsl:call-template name="callClassInheritance">
                        <xsl:with-param name="paramValue"><xsl:value-of select="@draw:style-name" /></xsl:with-param>
                    </xsl:call-template>
                </xsl:if>
                <xsl:if test="@draw:text-style-name">
                    <xsl:text> </xsl:text><xsl:value-of select="@draw:text-style-name" />
                </xsl:if>
            </xsl:attribute>
            <xsl:attribute name="style">
                <xsl:apply-templates select="." mode="attribs" />
            </xsl:attribute>
        <xsl:apply-templates />
        </xsl:element>
    </xsl:template>

    <!-- add the drawing element's properties in the inline CSS for this object -->
    <xsl:template match="draw:rect" mode="attribs">
        <xsl:if test="@svg:width">width: <xsl:value-of select="@svg:width" />; </xsl:if>
        <xsl:if test="@svg:height">height: <xsl:value-of select="@svg:height" />; </xsl:if>
        <xsl:if test="@draw:z-index">z-index: <xsl:value-of select="@draw:z-index" />; </xsl:if>
    </xsl:template>

<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

    <xsl:template match="number:number-style|number:number|number:scientific-number|number:fraction|
            number:currency-style|number:currency-symbol|number:text|style:map">
        <!-- do nothing for now for items we cannot interpret -->
    </xsl:template>

<!-- COMMON Items for all text and spreadsheet documents END - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

<!-- TEXT_DOCUMENT-SPECIFIC templates -->

    <!-- none as of this writing -->

<!-- - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -->

<!-- others -->

    <xsl:template match="office:annotation|dc:creator|dc:date|meta:date-string">
        <!-- do not handle these tags for this mimetype, since by default, these annotation items are also not displayed to user -->
    </xsl:template>

</xsl:stylesheet>
